<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./vue2.6.14.js"></script>
    <!-- <script src="./vue.3.2.21.js"></script> -->
</head>

<body>
    <div id="app">
        <div>数据源15行： [{{list[0]}}.........{{list[14]}}]</div>
        <button @click="toggle">切换前10行或后10行 </button>
        <table>
            <tbody>
                <tr v-for="item in display" :key="item.id">
                    <td>{{item.id}}</td>
                    <td>{{item.title}}</td>
                </tr>
            </tbody>
        </table>
    </div>
    <script>
        let list = Array.from(Array(15)).map((v, i) => {
            return { id: "id" + (i + 1), title: "item " + (i + 1) }
        })
        let start10 = list.slice(0, 10)
        let end10 = list.slice(5, 15)
        console.log(start10, end10)
        /* vue2  示例  */
        var app = new Vue({
            el: '#app',
            data: {
                list,
                flag:true,
                display:start10
            },
            methods:{
                toggle(){
                    this.flag=!this.flag
                    this.display=this.flag?start10:end10
                }
            }
        })
        /* vue3 示例  */
        // const App = {
        //     data() {
        //         return {
        //             list,
        //             flag: true,
        //             display: start10
        //         }
        //     },
        //     methods: {
        //         toggle() {
        //             this.flag = !this.flag
        //             this.display = this.flag ? start10 : end10
        //         }
        //     }
        // }

        // Vue.createApp(App).mount('#app')
    </script>
</body>

</html>